
from routes import db, login_manager
from sqlalchemy import Integer, String, BLOB, TIMESTAMP,Column, DECIMAL,String
from sqlalchemy.orm import Mapped, mapped_column

class Gep(db.Model):
    __tablename__ = 'gep_data'

    id = db.Column(db.Integer, primary_key=True)
    gepCity = db.Column(db.String(255), nullable=False)
    gepDistrict = db.Column(db.String(255), nullable=False)
    gepTown = db.Column(db.String(255), nullable=False)
    year = db.Column(db.Integer, nullable=False)
    outWaterSourceConservation = db.Column(db.Float)
    outSoilConservation = db.Column(db.Float)
    outNegativeOxygenIons = db.Column(db.Float)
    outAirPurification = db.Column(db.Float)
    outWaterPurification = db.Column(db.Float)
    outCarbonSequestration = db.Column(db.Float)
    outOxygenRelease = db.Column(db.Float)
    outClimateRegulation = db.Column(db.Float)
    outCalcFloodRegulation = db.Column(db.Float)
    outCalcBiodiversityProtection = db.Column(db.Float)
    outCalcNoiseReduced = db.Column(db.Float)
    # 唯一性约束
    __table_args__ = (
        db.UniqueConstraint('gepCity', 'gepDistrict','gepTown','year', name='unique_region_year'),
    )

class GepTest(db.Model):
    __tablename__ = 'gep_test'

    year = db.Column(db.Integer, nullable=False, primary_key=True)
    gepCity = db.Column(db.String(255), nullable=False, primary_key=True)
    gepDistrict = db.Column(db.String(255), nullable=False, primary_key=True)
    gepTown = db.Column(db.String(255), nullable=False, primary_key=True)
    inAgricultural = db.Column(db.Float)
    inAnimalHusbandry = db.Column(db.Float)
    inForestry = db.Column(db.Float)
    inFishery = db.Column(db.Float)
    inEcologicalEnergy = db.Column(db.Float)
    inWaterResources = db.Column(db.Float)
    inLocalWaterPrice = db.Column(db.Float)
    inProtectedArea = db.Column(db.Float)
    inProtectedCost = db.Column(db.Float)
    inReservoirCapacity = db.Column(db.Float)
    inReservoirCost = db.Column(db.Float)
    inHighwayMileage = db.Column(db.Float)
    inHighwayGreeningDegree = db.Column(db.Float)
    inTourismRevenue = db.Column(db.Float)
    inDisposableIncome = db.Column(db.Float)
    inGreenSpacePerCapita = db.Column(db.Float)
    inUrbanPopulation = db.Column(db.Float)
    inHotelRooms = db.Column(db.Float)
    inRoomPrice = db.Column(db.Float)
    inHousingAreaPerCapita = db.Column(db.Float)
    # 唯一性约束
    __table_args__ = (
        db.UniqueConstraint('gepCity', 'gepDistrict','gepTown','year', name='unique_region_year'),
    )

